www.gusucode.com > VC++ 单文档程序源码 > VC++ 单文档程序源码/MyQwindow/MyQwindowView.cpp

    // MyQwindowView.cpp : implementation of the CMyQwindowView class
//

#include "stdafx.h"
#include "MyQwindow.h"

#include "MyQwindowDoc.h"
#include "MyQwindowView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define BMP_SIZE 11520000
/////////////////////////////////////////////////////////////////////////////
// CMyQwindowView

IMPLEMENT_DYNCREATE(CMyQwindowView, CView)

BEGIN_MESSAGE_MAP(CMyQwindowView, CView)
	//{{AFX_MSG_MAP(CMyQwindowView)
	ON_WM_TIMER()
	ON_WM_CANCELMODE()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
	ON_MESSAGE(WM_CHILDFRAMEDBCLK,OnChlidFrameDBClick)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyQwindowView construction/destruction

CMyQwindowView::CMyQwindowView()
{
	// TODO: add construction code here

	m_pb1=NULL;
	m_pb2=NULL;
	m_pb3=NULL;
}

CMyQwindowView::~CMyQwindowView()
{
}

BOOL CMyQwindowView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMyQwindowView drawing

void CMyQwindowView::OnDraw(CDC* pDC)
{
	CMyQwindowDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMyQwindowView printing

BOOL CMyQwindowView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMyQwindowView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMyQwindowView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CMyQwindowView diagnostics

#ifdef _DEBUG
void CMyQwindowView::AssertValid() const
{
	CView::AssertValid();
}

void CMyQwindowView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMyQwindowDoc* CMyQwindowView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyQwindowDoc)));
	return (CMyQwindowDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyQwindowView message handlers

void CMyQwindowView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(m_nCount>=64&&m_nCase==1)
	{
		m_nCase=2;
		m_nCount=0;
	}
	else if(m_nCount>=64&&m_nCase==3)
	{
		//OnMystop();
	//	MessageBox("演示完毕","完毕",MB_OK);
	}
	else
	{
		if(m_nCase==1)
		{
			m_nCount++;
			for(int i=0;i<BMP_SIZE;i++)
				m_pb3[i]=m_nCount*m_pb1[i]/64;

		//	StretchDIBits(GetDC()->m_hDC,0,0,266,200,0,0,266,200,m_pb3,((BITMAPINFO*)(&m_header)),DIB_RGB_COLORS,SRCCOPY);
			StretchDIBits(GetDC()->m_hDC,0,0,800,600,0,0,800,600,m_pb3,((BITMAPINFO*)(&m_header)),DIB_RGB_COLORS,SRCCOPY);
		}
		else if(m_nCase==2)
		{
			m_nCount++;
			for(int i=0;i<BMP_SIZE;i++)
				m_pb3[i]=((64-m_nCount)*m_pb1[i]+m_nCount*m_pb2[i])/64;

		//	StretchDIBits(GetDC()->m_hDC,0,0,266,200,0,0,266,200,m_pb3,((BITMAPINFO*)(&m_header)),DIB_RGB_COLORS,SRCCOPY);
			StretchDIBits(GetDC()->m_hDC,0,0,800,600,0,0,800,600,m_pb3,((BITMAPINFO*)(&m_header)),DIB_RGB_COLORS,SRCCOPY);

			if(m_nCount>=64)
				m_nCase=3;
		}
	}
//	CView::OnTimer(nIDEvent);
}

void CMyQwindowView::OnCancelMode() 
{
	CView::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

void CMyQwindowView::StartDemo()
{
	  if(m_pb1==NULL)
		 {
		    m_nCount=0;
			m_nCase=1;

			CFile f1,f2;
			f1.Open("bmp1.bmp",CFile::modeRead,NULL);
			f1.Seek(14,CFile::begin);
			f1.Read(&m_header,40);
			CString str;
			str.Format("%d",m_header.biBitCount*m_header.biHeight*m_header.biWidth);
		//	MessageBox(str);
			f2.Open("bmp2.bmp",CFile::modeRead,NULL);
			f2.Seek(14,CFile::begin);
			f2.Read(&m_header,40);

			m_pb1=(BYTE*)malloc(BMP_SIZE);
			m_pb2=(BYTE*)malloc(BMP_SIZE);
			m_pb3=(BYTE*)malloc(BMP_SIZE);

			f1.ReadHuge(m_pb1,BMP_SIZE);
			f2.ReadHuge(m_pb2,BMP_SIZE);


			f1.Close();
			f2.Close();


			SetTimer(1,100,NULL);
		}
}

LRESULT CMyQwindowView::OnChlidFrameDBClick(WPARAM wParam,LPARAM lParam)
{
	MessageBox("dsafsaf");
	return TRUE;
}